﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;

namespace Lead2012.Business
{
    public class LeadStatusActionTypeRepository
    {
        // Create an instance of entity
        Lead2012Entities entities = new Lead2012Entities();
        
        public LeadStatusActionType GetSingle(int statusId, int typeId)
        {
            return (from _object in entities.LeadStatusActionTypes where _object.StatusId == statusId && _object.TypeId == typeId select _object).FirstOrDefault();
        }

        public void Create(LeadStatusActionType _object)
        {
            entities.AddToLeadStatusActionTypes(_object);
            entities.SaveChanges();
        }

        public void Update(LeadStatusActionType _object)
        {
            entities.SaveChanges();
        }
        public void Delete(int statusId, int typeId)
        {
            var _object = (from _list in entities.LeadStatusActionTypes where _list.StatusId == statusId && _list.TypeId == typeId select _list).First();
            entities.DeleteObject(_object);
            entities.SaveChanges();
        }
        public void Save(LeadStatusActionType _object)
        {
            _object.EntityKey = (from LeadStatusActionType ac in entities.LeadStatusActionTypes where ac.StatusId == _object.StatusId && ac.TypeId == _object.TypeId select ac).FirstOrDefault().EntityKey;
            entities.SaveChanges();
        }
    }
}